home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / misc / wexmast / wexmaster.pro < prev    next >
Text File  |  1997-07-08  |  12KB  |  390 lines

  1. ; $Id: wexmaster.pro,v 1.11 1997/01/15 04:29:15 ali Exp $
  2. ;
  3. ; Copyright (c) 1991-1997, Research Systems, Inc.  All rights reserved.
  4. ;    Unauthorized reproduction prohibited.
  5. ;+
  6. ; NAME:
  7. ;    WEXMASTER.PRO
  8. ; PURPOSE:
  9. ;    This routine is the main menu for the "Simple Widget Examples".
  10. ;    Click on any of the buttons in the menu to see helpful examples
  11. ;    of Widgets programming.
  12. ;
  13. ;    The examples under "Simple Widget Examples:" demonstrate the creation
  14. ;    and management of just one or two kinds of widgets at one time.
  15. ;    For more complex examples, select the examples under "Example Widget
  16. ;    Applications".
  17. ;
  18. ;    Select "About the Simple Widget Examples" to see a more information on
  19. ;    the simple widget examples.  Select "Widget Programming Tips and Tech-
  20. ;    niques" to see helpful information on programming with the IDL/widgets,
  21. ;    and widgets documentation updates.
  22. ;
  23. ;    Hope this helps!
  24. ; CATEGORY:
  25. ;    Widgets
  26. ; CALLING SEQUENCE:
  27. ;    WEXMASTER
  28. ; KEYWORD PARAMETERS:
  29. ;    GROUP = The widget ID of the widget that calls WEXMASTER.  When this
  30. ;        ID is specified, a death of the caller results in a death of
  31. ;        WEXMASTER.
  32. ; SIDE EFFECTS:
  33. ;    Initiates the XManager if it is not already running.
  34. ; RESTRICTIONS: Only one copy may run at a time to avoid confusion.
  35. ; PROCEDURE:
  36. ;    Create and register the widget and then exit.
  37. ; MODIFICATION HISTORY:
  38. ;    WEXMASTER and associated examples by Keith R Crosley, August, 1991
  39. ;    Created from a template written by: Steve Richards,    January, 1991
  40. ;-
  41.  
  42.  
  43.  
  44.  
  45.  
  46. ;------------------------------------------------------------------------------
  47. PRO wexmaster_event, event
  48.  
  49. WIDGET_CONTROL, event.id, GET_UVALUE = eventval
  50.                             ;find the user value
  51.                             ;of the widget where
  52.                             ;the event occured
  53. ; Set the width of the XDISPLAYFILE windows:
  54. X=90
  55.  
  56. IF eventval EQ 'THEMENU' THEN BEGIN
  57.  
  58. CASE event.value OF
  59.  
  60.   "XLoadct": XLoadct, GROUP = event.top            ;XLoadct is the library
  61.                             ;routine that lets you
  62.                             ;select and adjust the
  63.                             ;color palette being
  64.                             ;used.
  65.  
  66.   "XPalette": XPalette, GROUP = event.top        ;XPalette is the
  67.                             ;library routine that
  68.                             ;lets you adjust 
  69.                             ;individual color
  70.                             ;values in the palette.
  71.  
  72.   "XManagerTool": XMTool, GROUP = event.top        ;XManTool is a library
  73.                             ;routine that shows 
  74.                             ;which widget
  75.                             ;applications are 
  76.                             ;currently registered
  77.                             ;with the XManager as
  78.                             ;well as which
  79.                             ;background tasks.
  80.  
  81.   "About the Simple Widget Examples"    : $
  82.             XDISPLAYFILE,FILEPATH('simpwidg.txt', $
  83.             SUBDIR=['examples', 'misc', 'wexmast']),$
  84.               TITLE = 'About the Simple Widget Examples', $
  85.             GROUP=event.top
  86.  
  87.   "Widget Programming Tips and Techniques" : $
  88.             XDISPLAYFILE, FILEPATH('wtips.txt', $
  89.             SUBDIR=['examples', 'misc', 'wexmast']),$
  90.               TITLE = 'Widget Programming Tips and Techniques', $
  91.             GROUP=event.top
  92.  
  93.   "Done" : WIDGET_CONTROL, event.top, /DESTROY        ;There is no need to
  94.                             ;"unregister" a widget
  95.                             ;application.  The
  96.                             ;XManager will clean
  97.                             ;the dead widget from
  98.                             ;its list.
  99.  
  100. ENDCASE ; The Menu
  101.  
  102. ENDIF ELSE IF eventval EQ "SIMPLE" THEN BEGIN
  103.  
  104. CASE event.index OF
  105.  
  106.         0: BEGIN
  107.            XDISTFILE, 'mbar', ['examples', 'misc', 'wexmast'], $
  108.             GROUP = event.top, WIDTH=X
  109.            MBAR, GROUP = event.top
  110.            ENDCASE
  111.         
  112.         1: BEGIN
  113.            XDISTFILE, 'wslider',['examples', 'misc', 'wexmast'], $ 
  114.             GROUP = event.top, WIDTH=X
  115.            WSLIDER, GROUP = event.top
  116.            ENDCASE
  117.         
  118.                 2: BEGIN
  119.                    XDISTFILE, 'wvertical', ['examples', 'misc', 'wexmast'], $ 
  120.                         GROUP = event.top, WIDTH=X
  121.                    WVERTICAL, GROUP = event.top
  122.                    ENDCASE
  123.         
  124.         3: BEGIN
  125.            XDISTFILE, 'wbuttons', ['examples', 'misc', 'wexmast'], $ 
  126.                         GROUP = event.top, WIDTH=X
  127.            WBUTTONS, GROUP = event.top
  128.            ENDCASE
  129.  
  130.         4: BEGIN
  131.            XDISTFILE, 'wbitmap', ['examples', 'misc', 'wexmast'], $ 
  132.             GROUP = event.top, WIDTH=X
  133.            WBITMAP, GROUP = event.top
  134.            ENDCASE
  135.  
  136.                 5: BEGIN
  137.                    XDISTFILE, 'wtoggle', ['examples', 'misc', 'wexmast'], $ 
  138.                         GROUP = event.top, WIDTH=X
  139.                    WTOGGLE, GROUP = event.top
  140.                    ENDCASE
  141.  
  142.         6: BEGIN
  143.                    XDISTFILE, 'wtext', ['examples', 'misc', 'wexmast'], $ 
  144.                         GROUP = event.top, WIDTH=X
  145.                    WTEXT, GROUP = event.top
  146.                    ENDCASE
  147.  
  148.         7: BEGIN
  149.            XDISTFILE, 'wlabel', ['examples', 'misc', 'wexmast'], $ 
  150.                         GROUP = event.top, WIDTH=X
  151.                    WLABEL, GROUP = event.top
  152.                    ENDCASE
  153.  
  154.                 8: BEGIN
  155.                    XDISTFILE, 'wlabtext', ['examples', 'misc', 'wexmast'], $ 
  156.                         GROUP = event.top, WIDTH=X
  157.                    WLABTEXT, GROUP = event.top
  158.                    ENDCASE
  159.  
  160.                 9: BEGIN
  161.                    XDISTFILE, 'wlist', ['examples', 'misc', 'wexmast'], $ 
  162.                         GROUP = event.top, WIDTH=X
  163.                    WLIST, GROUP = event.top
  164.                    ENDCASE
  165.  
  166.                10: BEGIN
  167.                    XDISTFILE, 'wdroplist', ['examples', 'misc', 'wexmast'], $ 
  168.                         GROUP = event.top, WIDTH=X
  169.                    WDROPLIST, GROUP = event.top
  170.                    ENDCASE
  171.  
  172.  
  173.                11: BEGIN
  174.                    XDISTFILE, 'wmtest', ['examples', 'misc', 'wexmast'], $ 
  175.                         GROUP = event.top, WIDTH=X
  176.                    WMTEST, GROUP = event.top
  177.                    ENDCASE
  178.  
  179.                12: BEGIN
  180.                    XDISTFILE, 'wpdmenu', ['examples', 'misc', 'wexmast'], $ 
  181.                         GROUP = event.top, WIDTH=X
  182.                    WPDMENU, GROUP = event.top
  183.                    ENDCASE
  184.  
  185.                13: BEGIN
  186.                    XDISTFILE, 'wexclus', ['examples', 'misc', 'wexmast'], $ 
  187.                         GROUP = event.top, WIDTH=X
  188.                    WEXCLUS, GROUP = event.top
  189.                    ENDCASE
  190.  
  191.                14: BEGIN
  192.                    XDISTFILE, 'w2menus', ['examples', 'misc', 'wexmast'], $ 
  193.                         GROUP = event.top, WIDTH=X
  194.                    W2MENUS, GROUP = event.top
  195.                    ENDCASE
  196.  
  197.                15: BEGIN
  198.                    XDISTFILE, 'wpopup', ['examples', 'misc', 'wexmast'], $
  199.                         GROUP = event.top, WIDTH=X
  200.                    WPOPUP, GROUP = event.top
  201.                    ENDCASE
  202.  
  203.                16: BEGIN
  204.                    XDISTFILE, 'wdraw', ['examples', 'misc', 'wexmast'], $
  205.                         GROUP = event.top, WIDTH=X
  206.                    WDRAW, GROUP = event.top
  207.                    ENDCASE
  208.  
  209.                17: BEGIN
  210.                    XDISTFILE, 'wdr_scrl', ['examples', 'misc', 'wexmast'], $
  211.                         GROUP = event.top, WIDTH=X
  212.                    WDR_SCRL, GROUP = event.top
  213.                    ENDCASE
  214.  
  215.                18: BEGIN
  216.                    XDISTFILE, 'wmotion', ['examples', 'misc', 'wexmast'], $
  217.                         GROUP = event.top, WIDTH=X
  218.                    WMOTION, GROUP = event.top
  219.                    ENDCASE
  220.  
  221.                19: BEGIN
  222.                    XDISTFILE, 'wsens', ['examples', 'misc', 'wexmast'], $
  223.                         GROUP = event.top, WIDTH=X
  224.                    WSENS, GROUP = event.top
  225.                    ENDCASE
  226.  
  227.                20: BEGIN
  228.                    XDISTFILE, 'wback', ['examples', 'misc', 'wexmast'], $
  229.                         GROUP = event.top, WIDTH=X
  230.                    WBACK, GROUP = event.top
  231.                    ENDCASE
  232.  
  233.                21: BEGIN
  234.                    XDISTFILE, 'wxreg', ['examples', 'misc', 'wexmast'], $
  235.                         GROUP = event.top, WIDTH=X
  236.                    WXREG, GROUP = event.top
  237.                    ENDCASE
  238.         
  239. ENDCASE ;SIMPLE case.
  240.  
  241. ENDIF ELSE IF eventval EQ "APPS" THEN BEGIN
  242.  
  243. CASE event.index OF
  244.  
  245.                 0: BEGIN
  246.                    XDISTFILE, 'worlddemo', ['examples', 'misc', 'wexmast'], $ 
  247.                         GROUP = event.top, WIDTH=X
  248.                    OPENR, UNIT, /GET_LUN, FILEPATH('worldelv.dat', $
  249.                           sub=['examples', 'data'])
  250.                    im = BYTARR(360, 360, /NOZERO)
  251.                    READU, unit, im
  252.                    FREE_LUN, unit
  253.                    im = SHIFT(im, 180, 0)
  254.                    WORLDDEMO, BYTSCL(IM, TOP=!D.N_COLORS-1), GROUP = event.top
  255.                    ENDCASE
  256.  
  257.                  1: BEGIN
  258.                    XDISTFILE, 'slots', ['examples', 'misc', 'wexmast'], $
  259.                         GROUP = event.top, WIDTH=X
  260.                    SLOTS, GROUP = event.top
  261.                    ENDCASE
  262.  
  263.                 2: BEGIN
  264.                    XDISTFILE, 'xmng_tmpl', ['lib'], $
  265.                         GROUP = event.top, WIDTH=X
  266.                    XMNG_TMPL, GROUP = event.top
  267.                    ENDCASE
  268.  
  269. ;                3: BEGIN
  270. ;                   XDISTFILE, 'xexample', ['lib','demo','xdemo'], $
  271. ;                        GROUP = event.top, WIDTH=X
  272. ;                   XEXAMPLE, GROUP = event.top
  273. ;                   ENDCASE
  274.  
  275.                 3: BEGIN
  276.                    XDISTFILE, 'xsurface', ['lib'], $
  277.                         GROUP = event.top, WIDTH=X
  278.                    XSURFACE, DIST(20), GROUP = event.top
  279.                    ENDCASE
  280.  
  281.                 4: BEGIN
  282.                    XDISTFILE, 'xbm_edit', ['lib'], $
  283.                         GROUP = event.top, WIDTH=X
  284.                    XBM_EDIT, GROUP = event.top
  285.                    ENDCASE
  286. ENDCASE ;APPS case
  287.  
  288. ENDIF ELSE MESSAGE, "Event User Value Not Found"    ;When an event occurs
  289.                             ;in a widget that has
  290.                             ;no user value in this
  291.                             ;case statement, an
  292.                             ;error message is shown
  293.  
  294. END ;============= end of WEXMASTER event handling routine task =============
  295.  
  296.  
  297.  
  298.  
  299. ;------------------------------------------------------------------------------
  300. PRO wexmaster, GROUP = GROUP
  301.  
  302. IF(XRegistered("wexmaster") NE 0) THEN RETURN        ;only one instance of
  303.                             ;the Wexmaster widget
  304.                             ;is allowed.  If it is
  305.                             ;already managed, do
  306.                             ;nothing and return
  307.  
  308. ;The main base.
  309. XMng_tmplbase = WIDGET_BASE(TITLE = "Simple Widget Examples",/COLUMN,MBAR=mbar)
  310.  
  311. menu = CW_PdMenu(mbar, /RETURN_NAME, /MBAR, /HELP, $
  312.                  ['1\File', $
  313.                   '2\Done', $
  314.                   '1\Tools', $
  315.                   '0\XLoadct', $
  316.                   '0\XPalette', $
  317.                   '2\XManagerTool', $
  318.                   '1\Help', $
  319.                   '0\About the Simple Widget Examples', $
  320.                   '2\Widget Programming Tips and Techniques'], $
  321.                  UVALUE='THEMENU')
  322.  
  323. ; Make a new sub-base:
  324. base = WIDGET_BASE(xmng_tmplbase, /ROW)
  325.  
  326. lcol = WIDGET_BASE(base, /COLUMN)    ;The left column.
  327. rcol = WIDGET_BASE(base, /COLUMN)
  328.  
  329. llabel = WIDGET_LABEL(lcol, VALUE = 'Simple Widget Examples:')
  330.  
  331. ;Define the top pulldown labels:
  332.  
  333. buttons = ['Menu Bar', $
  334.         'Horizontal Slider', $
  335.     'Vertical Slider', $
  336.     'Action Buttons', $
  337.     'Bitmap Button', $
  338.     'Toggle Buttons', $
  339.     'Text Widgets', $
  340.     'Label Widgets', $
  341.     'Combination Label/Text Widgets', $
  342.     'List Widget', $
  343.     'Droplist Widget', $
  344.     'Non-Exclusive Menu', $
  345.     'Pull-Down Menu', $
  346.     'Exclusive Menu', $
  347.     'Two Menus', $
  348.     'Pop-Up Widget', $
  349.     'Draw Widget', $
  350.     'Scrolling Draw Widget', $
  351.     'Motion Events Draw Widget', $
  352.     'Sensitizing/Desensitizing', $
  353.     'Timer Task Widget', $
  354.     'Multiple Copies of a Widget']
  355.  
  356.  
  357. list = WIDGET_LIST(lcol, VALUE=buttons, YSIZE = 10, $
  358.            /FRAME, UVALUE = 'SIMPLE')
  359.  
  360. buttons2 = ['World Rotation Tool', $
  361.         'Slot Machine Demo', $
  362. ;        'Widgets Template', $
  363.         'All Widget Types Example', $
  364.         'XSURFACE Tool', $
  365.         'Bitmap Editor']
  366.  
  367. ; Right column has the super-cool example programs written by Keith:
  368.  
  369. mlabel = WIDGET_LABEL(rcol, VALUE = 'Example Widget Applications:')
  370.  
  371. list2 = WIDGET_LIST(rcol, VALUE=buttons2, YSIZE=10, $
  372.                     /FRAME, UVALUE = 'APPS')
  373.  
  374.  
  375.  
  376.  
  377. ; Realize the widgets:
  378. WIDGET_CONTROL, XMng_tmplbase, /REALIZE        
  379.  
  380. XManager, "wexmaster", XMng_tmplbase, $            ;register the widgets,
  381.         GROUP_LEADER = GROUP, /NO_BLOCK      ;with the XManager
  382.                             ;and pass through the
  383.                             ;group leader if this
  384.                             ;routine is to be 
  385.                             ;called from some group
  386.                             ;leader.
  387.  
  388. END ;==================== end of WEXMASTER main routine =======================
  389.  
  390.